package com.yoga.manager.beanUtil;

import com.yoga.common.bo.PhotoAlbumBO;
import com.yoga.dao.domain.PhotoAlbumDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类PhotoAlbumBeanUtil.java的实现描述：工具类
 *
 * @Author hdx
 * @Date 2020年10月20日
 */
public class PhotoAlbumBeanUtil {

    private PhotoAlbumBeanUtil() {
    }

    public static PhotoAlbumDO photoAlbumBOToDO(PhotoAlbumBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        PhotoAlbumDO targetObj = new PhotoAlbumDO();
        targetObj.setId(srcObj.getPhotoAlbumId());//id
        targetObj.setTitleName(srcObj.getTitleName());//标题
        targetObj.setPhotoUrl(srcObj.getPhotoUrl());//图片集合
        targetObj.setPhotoType(srcObj.getPhotoType());//类型：1、精美相册，2、轮播图，3、场馆环境
        targetObj.setDeleted(srcObj.getDeleted());//deleted
        targetObj.setCreateDate(srcObj.getCreateDate());//createDate
        targetObj.setUpdateDate(srcObj.getUpdateDate());//updateDate
        return targetObj;
    }

    public static PhotoAlbumBO photoAlbumDOToBO(PhotoAlbumDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        PhotoAlbumBO targetObj = new PhotoAlbumBO();
        targetObj.setPhotoAlbumId(srcObj.getId());//id
        targetObj.setTitleName(srcObj.getTitleName());//标题
        targetObj.setPhotoUrl(srcObj.getPhotoUrl());//图片集合
        targetObj.setPhotoType(srcObj.getPhotoType());//类型：1、精美相册，2、轮播图，3、场馆环境
        targetObj.setDeleted(srcObj.getDeleted());//deleted
        targetObj.setCreateDate(srcObj.getCreateDate());//createDate
        targetObj.setUpdateDate(srcObj.getUpdateDate());//updateDate
        return targetObj;
    }

    public static List<PhotoAlbumBO> doList2BOList(List<PhotoAlbumDO> doList) {
        List<PhotoAlbumBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        doList.stream().forEach(photoAlbumDO -> boList.add(PhotoAlbumBeanUtil.photoAlbumDOToBO(photoAlbumDO)));

        return boList;
    }

}